package com.magenta.maxoptra.gis.distancematrix.commands;

import com.magenta.maxoptra.gis.distancematrix.CommandType;
import com.magenta.maxoptra.gis.distancematrix.DistanceMatrixDAO;
import com.magenta.maxoptra.gis.distancematrix.DistanceMatrixServiceProxy;
import com.magenta.maxoptra.gis.distancematrix.UpdateRequestType;

/**
 * @author Sergey Grachev
 */
final class StopGroup extends AbstractGroupCommand {

    StopGroup(final long groupId) {
        super(groupId);
    }

    @Override
    public void execute(final DistanceMatrixDAO db, final DistanceMatrixServiceProxy service) {
        groupContext.stopUpdating();
        service.stopGroupUpdating(groupContext.getId());
    }

    @Override
    public CommandType getType() {
        return CommandType.STOP;
    }

    @Override
    public UpdateRequestType isRequireMatrixUpdating() {
        return UpdateRequestType.NONE;
    }

    @Override
    public boolean isRequireGroupLock() {
        return true;
    }

    @Override
    public String toString() {
        return "StopGroup{" +
                "groupId=" + groupId +
                '}';
    }
}
